package com.example.a17376052_wcp_finaltest.fragment;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.example.a17376052_wcp_finaltest.R;
import java.util.ArrayList;
import java.util.List;

import adapter.FruitAdapter;
import entire.Fruit;
public class Fragment_3 extends Fragment {
    private ListView fruitListView;
    private List<Fruit> fruitList = new ArrayList<Fruit>();
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.fragment_3, null);



        fruitListView = (ListView) view.findViewById(R.id.fruitListView2);

        fruitList.add(new Fruit("Tom",R.mipmap.tom));
        fruitList.add(new Fruit("我的订单",R.mipmap.cbbb));
        fruitList.add(new Fruit("我的收藏",R.mipmap.czzzz));
        fruitList.add(new Fruit("设置", R.mipmap.cici));
        fruitList.add(new Fruit("常见问题", R.mipmap.crti));
        fruitList.add(new Fruit("关于我们", R.mipmap.csdi));
        fruitList.add(new Fruit("收货地址", R.mipmap.cvii));
        fruitList.add(new Fruit("关于我们", R.mipmap.cvui));


        FruitAdapter adapter = new FruitAdapter(getActivity(), R.layout.fruit_item,fruitList);
        fruitListView.setAdapter(adapter);

        fruitListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(getActivity(),"谢谢你这么好看还关注我"+position,Toast.LENGTH_SHORT).show();
                Intent intent=new Intent(getActivity(),Main5Activity.class);
                startActivity(intent);

            }
        });
        return view;
    }



}
